package com.imooc.example.springtxpa.service;

import com.imooc.example.springtxpa.dao.CustomerRepository;
import com.imooc.example.springtxpa.domain.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author linzou@linkdoc.com
 * @ClassName: CustomerServiceInAnnotation
 * @Description:
 * @date 2019/1/1 11:59 AM
 */
@Service
public class CustomerServiceInAnnotation {

    @Autowired
    private CustomerRepository customerRepository;

    @Transactional(rollbackFor = Exception.class)
    public Customer create(Customer customer){
        return customerRepository.save(customer);
    }


}
